﻿

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using System.Data;
using System.Data.Sql;
using Microsoft.Office.Interop.Excel;
using System.IO.Ports;
namespace ConsoleApplication1
{
    class Program
    {
        int[] a;

        private void func(String str)
        {
            
            Console.WriteLine(str);
        }

        static void Main(string[] args)
        {
            SerialPort port = new SerialPort();
            port.PortName = "COM1";
            port.Parity = Parity.None;
            port.DataBits = 8;
            port.StopBits = StopBits.One;
            port.WriteTimeout = 1000;
            port.ReadTimeout = 1000;
            port.Open();
            if (!port.IsOpen)
            {
                Console.WriteLine("打开失败");
            }
            try
            {
                port.WriteLine("Hellow World");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
       
        }

    }
}
